package com.lbh.model;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.print.attribute.standard.JobName;

import org.apache.commons.lang3.StringUtils;

import com.google.common.collect.Lists;
import com.jfinal.ext.plugin.tablebind.TableBind;
import com.jfinal.plugin.activerecord.Model;

public class JobModel extends Model<JobModel> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1170012157127821972L;
	public static final JobModel JOB = new JobModel();
	/**
	 * 
	 * CREATE TABLE `job` ( `id` int(11) NOT NULL , `cron` varchar(255)
	 * CHARACTER SET utf8 NOT NULL DEFAULT '' COMMENT 'cron表达式' , `time`
	 * datetime NOT NULL COMMENT '创建时间' , `content` varchar(255) CHARACTER SET
	 * utf8 NOT NULL DEFAULT '' COMMENT '备注' , `type` varchar(255) CHARACTER SET
	 * utf8 NULL DEFAULT 1 COMMENT '类型 1、开启;2、关闭' , PRIMARY KEY (`id`) ) ;
	 * 
	 * 
	 * ALTER TABLE `job` ADD COLUMN `jobName` varchar(255) NULL AFTER `type`,
	 * ADD COLUMN `groupName` varchar(255) NULL AFTER `jobName`, ADD COLUMN
	 * `triggerName` varchar(255) NULL AFTER `groupName`;
	 * 
	 * 
	 */

	public static final String ID = "id";
	public static final String CRON = "cron";
	public static final String TIME = "time";
	public static final String CONTENT = "content";
	public static final String TYPE = "type";
	public static final String JOBNAME = "jobName";
	public static final String GROUPNAME = "groupName";
	public static final String TRIGGERNAME = "triggerName";
	

	public Integer getId() {
		return this.getInt(ID);
	}

	public void setId(Long id) {
		this.set(ID, id);
	}

	public String getCron() {
		return this.getStr(CRON);
	}

	public void setAccount(String cron) {
		this.set(CRON, cron);
	}

	public Date getTime() {
		return this.getDate(TIME);
	}

	public void setTime(String time) {
		this.set(TIME, time);
	}

	public String getContent() {
		return this.getStr(CONTENT);
	}

	public void setContent(String content) {
		this.set(CONTENT, content);
	}

	public String getType() {
		return this.getStr(TYPE);
	}

	public void setType(String type) {
		this.set(TYPE, type);
	}
	
	public String getJobName() {
		return this.getStr(JOBNAME);
	}

	public void setJobName(String jobName) {
		this.set(JOBNAME,jobName);
	}
	
	public String getGroupName() {
		return this.getStr(GROUPNAME);
	}

	public void setGroupName(String groupName) {
		this.set(GROUPNAME,groupName);
	}
	
	public String getTriggerName() {
		return this.getStr(TRIGGERNAME);
	}

	public void setTriggerName(String triggerName) {
		this.set(TRIGGERNAME,triggerName);
	}

	public List<JobModel> getJob() {
		return this.find("select * from job");
	}

	public JobModel getJob(String id) {
		String sql = " select * from job where id = ? limit 1";
		return this.findFirst(sql, id);
	}
}
